<template>
  <div class="log-management-bg">
    <div class="log-management-center">
      <!-- 页面标题区域 -->
      <div class="log-header">
        <div class="log-avatar">
          <i class="el-icon-document"></i>
        </div>
        <div class="log-title">日志管理</div>
        <div class="log-subtitle">查看系统操作日志和审计记录</div>
      </div>

      <!-- 日志统计卡片 -->
      <div class="log-overview">
        <el-row :gutter="20">
          <el-col :span="6">
            <div class="overview-card">
              <div class="card-icon">
                <i class="el-icon-user"></i>
              </div>
              <div class="card-content">
                <div class="card-number">{{ totalLogs }}</div>
                <div class="card-label">总日志数</div>
              </div>
            </div>
          </el-col>
          <el-col :span="6">
            <div class="overview-card">
              <div class="card-icon">
                <i class="el-icon-s-data"></i>
              </div>
              <div class="card-content">
                <div class="card-number">{{ todayLogs }}</div>
                <div class="card-label">今日日志</div>
              </div>
            </div>
          </el-col>
          <el-col :span="6">
            <div class="overview-card">
              <div class="card-icon">
                <i class="el-icon-warning"></i>
              </div>
              <div class="card-content">
                <div class="card-number">{{ errorLogs }}</div>
                <div class="card-label">错误日志</div>
              </div>
            </div>
          </el-col>
          <el-col :span="6">
            <div class="overview-card">
              <div class="card-icon">
                <i class="el-icon-s-custom"></i>
              </div>
              <div class="card-content">
                <div class="card-number">{{ activeUsers }}</div>
                <div class="card-label">活跃用户</div>
              </div>
            </div>
          </el-col>
        </el-row>
      </div>

      <!-- 日志管理区域 -->
      <div class="log-management">
        <!-- 查询条件 -->
        <div class="query-section">
          <el-card class="query-card">
            <template #header>
              <div class="card-header">
                <span>查询条件</span>
                <div class="header-actions">
                  <el-button type="primary" @click="handleQuery" :loading="queryLoading">
                    <el-icon><Search /></el-icon>
                    查询
                  </el-button>
                  <el-button @click="resetQuery">
                    <el-icon><Refresh /></el-icon>
                    重置
                  </el-button>
                  <el-button type="success" @click="exportLogs" :loading="exportLoading">
                    <el-icon><Download /></el-icon>
                    导出日志
                  </el-button>
                </div>
              </div>
            </template>
            
            <el-form :model="queryForm" label-width="100px" class="query-form">
              <el-row :gutter="20">
                <el-col :span="8">
                  <el-form-item label="时间范围">
                    <el-date-picker
                      v-model="queryForm.timeRange"
                      type="datetimerange"
                      range-separator="至"
                      start-placeholder="开始时间"
                      end-placeholder="结束时间"
                      format="YYYY-MM-DD HH:mm:ss"
                      value-format="YYYY-MM-DD HH:mm:ss"
                      style="width: 100%"
                    />
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item label="操作用户">
                    <el-input
                      v-model="queryForm.username"
                      placeholder="请输入用户名"
                      clearable
                    />
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item label="操作类型">
                    <el-select
                      v-model="queryForm.operationType"
                      placeholder="请选择操作类型"
                      clearable
                      style="width: 100%"
                    >
                      <el-option label="登录" value="login" />
                      <el-option label="登出" value="logout" />
                      <el-option label="查询" value="query" />
                      <el-option label="新增" value="create" />
                      <el-option label="修改" value="update" />
                      <el-option label="删除" value="delete" />
                      <el-option label="导出" value="export" />
                      <el-option label="导入" value="import" />
                      <el-option label="系统设置" value="settings" />
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="4">
                  <el-form-item label="日志级别">
                    <el-select
                      v-model="queryForm.logLevel"
                      placeholder="请选择级别"
                      clearable
                      style="width: 100%"
                    >
                      <el-option label="INFO" value="info" />
                      <el-option label="WARN" value="warn" />
                      <el-option label="ERROR" value="error" />
                      <el-option label="DEBUG" value="debug" />
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-row>
              
              <el-row :gutter="20">
                <el-col :span="8">
                  <el-form-item label="IP地址">
                    <el-input
                      v-model="queryForm.ipAddress"
                      placeholder="请输入IP地址"
                      clearable
                    />
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="模块名称">
                    <el-select
                      v-model="queryForm.module"
                      placeholder="请选择模块"
                      clearable
                      style="width: 100%"
                    >
                      <el-option label="用户管理" value="user" />
                      <el-option label="角色管理" value="role" />
                      <el-option label="菜单管理" value="menu" />
                      <el-option label="权限控制" value="permission" />
                      <el-option label="系统设置" value="system" />
                      <el-option label="日志管理" value="log" />
                      <el-option label="内容管理" value="content" />
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="状态">
                    <el-select
                      v-model="queryForm.status"
                      placeholder="请选择状态"
                      clearable
                      style="width: 100%"
                    >
                      <el-option label="成功" value="success" />
                      <el-option label="失败" value="failed" />
                      <el-option label="异常" value="exception" />
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-form>
          </el-card>
        </div>

        <!-- 日志列表 -->
        <div class="log-list-section">
          <el-card class="log-list-card">
            <template #header>
              <div class="card-header">
                <span>日志列表</span>
                <div class="header-actions">
                  <el-button type="primary" @click="refreshLogs" :loading="refreshLoading">
                    <el-icon><Refresh /></el-icon>
                    刷新
                  </el-button>
                  <el-button @click="clearLogs" :disabled="!isAdmin">
                    <el-icon><Delete /></el-icon>
                    清空日志
                  </el-button>
                </div>
              </div>
            </template>
            
            <el-table
              :data="logList"
              border
              style="width: 100%"
              :loading="tableLoading"
              @selection-change="handleSelectionChange"
            >
              <el-table-column type="selection" width="55" />
              <el-table-column prop="timestamp" label="时间" width="180" sortable>
                <template #default="scope">
                  {{ formatDateTime(scope.row.timestamp) }}
                </template>
              </el-table-column>
              <el-table-column prop="username" label="操作用户" width="120" />
              <el-table-column prop="operationType" label="操作类型" width="100">
                <template #default="scope">
                  <el-tag :type="getOperationTypeColor(scope.row.operationType)" size="small">
                    {{ getOperationTypeText(scope.row.operationType) }}
                  </el-tag>
                </template>
              </el-table-column>
              <el-table-column prop="module" label="模块" width="120" />
              <el-table-column prop="description" label="操作描述" min-width="200" />
              <el-table-column prop="ipAddress" label="IP地址" width="120" />
              <el-table-column prop="logLevel" label="级别" width="80">
                <template #default="scope">
                  <el-tag :type="getLogLevelColor(scope.row.logLevel)" size="small">
                    {{ scope.row.logLevel.toUpperCase() }}
                  </el-tag>
                </template>
              </el-table-column>
              <el-table-column prop="status" label="状态" width="80">
                <template #default="scope">
                  <el-tag :type="getStatusColor(scope.row.status)" size="small">
                    {{ getStatusText(scope.row.status) }}
                  </el-tag>
                </template>
              </el-table-column>
              <el-table-column prop="duration" label="耗时(ms)" width="100" />
              <el-table-column label="操作" width="120" fixed="right">
                <template #default="scope">
                  <el-button
                    type="primary"
                    size="small"
                    @click="viewLogDetail(scope.row)"
                  >
                    详情
                  </el-button>
                </template>
              </el-table-column>
            </el-table>

            <!-- 分页 -->
            <div class="pagination-container">
              <el-pagination
                v-model:current-page="currentPage"
                v-model:page-size="pageSize"
                :page-sizes="[10, 20, 50, 100]"
                :total="total"
                layout="total, sizes, prev, pager, next, jumper"
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
              />
            </div>
          </el-card>
        </div>
      </div>
    </div>

    <!-- 日志详情弹窗 -->
    <el-dialog
      v-model="logDetailVisible"
      title="日志详情"
      width="800px"
      class="log-detail-dialog"
    >
      <div v-if="selectedLog" class="log-detail">
        <el-descriptions :column="2" border>
          <el-descriptions-item label="时间">
            {{ formatDateTime(selectedLog.timestamp) }}
          </el-descriptions-item>
          <el-descriptions-item label="操作用户">
            {{ selectedLog.username }}
          </el-descriptions-item>
          <el-descriptions-item label="操作类型">
            <el-tag :type="getOperationTypeColor(selectedLog.operationType)" size="small">
              {{ getOperationTypeText(selectedLog.operationType) }}
            </el-tag>
          </el-descriptions-item>
          <el-descriptions-item label="模块">
            {{ selectedLog.module }}
          </el-descriptions-item>
          <el-descriptions-item label="IP地址">
            {{ selectedLog.ipAddress }}
          </el-descriptions-item>
          <el-descriptions-item label="用户代理">
            {{ selectedLog.userAgent }}
          </el-descriptions-item>
          <el-descriptions-item label="日志级别">
            <el-tag :type="getLogLevelColor(selectedLog.logLevel)" size="small">
              {{ selectedLog.logLevel.toUpperCase() }}
            </el-tag>
          </el-descriptions-item>
          <el-descriptions-item label="状态">
            <el-tag :type="getStatusColor(selectedLog.status)" size="small">
              {{ getStatusText(selectedLog.status) }}
            </el-tag>
          </el-descriptions-item>
          <el-descriptions-item label="耗时">
            {{ selectedLog.duration }}ms
          </el-descriptions-item>
          <el-descriptions-item label="请求方法">
            {{ selectedLog.requestMethod }}
          </el-descriptions-item>
        </el-descriptions>

        <div class="detail-section">
          <h5>操作描述</h5>
          <p>{{ selectedLog.description }}</p>
        </div>

        <div class="detail-section">
          <h5>请求参数</h5>
          <el-card class="detail-card">
            <pre>{{ selectedLog.requestParams }}</pre>
          </el-card>
        </div>

        <div class="detail-section">
          <h5>响应结果</h5>
          <el-card class="detail-card">
            <pre>{{ selectedLog.responseResult }}</pre>
          </el-card>
        </div>

        <div v-if="selectedLog.errorMessage" class="detail-section">
          <h5>错误信息</h5>
          <el-card class="detail-card error-card">
            <pre>{{ selectedLog.errorMessage }}</pre>
          </el-card>
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<script setup>
import { ref, reactive, computed, onMounted } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { 
  Search, Refresh, Download, Delete,
  Document, User, Warning, Setting
} from '@element-plus/icons-vue'

console.log('LogManagement组件已加载')

// 响应式数据
const isAdmin = ref(true) // 模拟当前用户是管理员
const queryLoading = ref(false)
const exportLoading = ref(false)
const refreshLoading = ref(false)
const tableLoading = ref(false)
const logDetailVisible = ref(false)
const selectedLog = ref(null)

// 统计数据
const totalLogs = ref(15678)
const todayLogs = ref(234)
const errorLogs = ref(45)
const activeUsers = ref(89)

// 查询表单
const queryForm = reactive({
  timeRange: [],
  username: '',
  operationType: '',
  logLevel: '',
  ipAddress: '',
  module: '',
  status: ''
})

// 分页数据
const currentPage = ref(1)
const pageSize = ref(20)
const total = ref(0)

// 日志列表
const logList = ref([])
const selectedLogs = ref([])

// 模拟日志数据
const mockLogData = [
  {
    id: 1,
    timestamp: new Date('2024-01-15 10:30:00'),
    username: 'admin',
    operationType: 'login',
    module: '用户管理',
    description: '用户登录系统',
    ipAddress: '192.168.1.100',
    userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
    logLevel: 'info',
    status: 'success',
    duration: 150,
    requestMethod: 'POST',
    requestParams: '{"username":"admin","password":"***"}',
    responseResult: '{"code":200,"message":"登录成功","data":{"token":"xxx"}}',
    errorMessage: null
  },
  {
    id: 2,
    timestamp: new Date('2024-01-15 10:35:00'),
    username: 'admin',
    operationType: 'create',
    module: '用户管理',
    description: '创建新用户：张三',
    ipAddress: '192.168.1.100',
    userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
    logLevel: 'info',
    status: 'success',
    duration: 320,
    requestMethod: 'POST',
    requestParams: '{"name":"张三","email":"zhangsan@example.com","role":"user"}',
    responseResult: '{"code":200,"message":"用户创建成功","data":{"id":123}}',
    errorMessage: null
  },
  {
    id: 3,
    timestamp: new Date('2024-01-15 10:40:00'),
    username: 'user1',
    operationType: 'update',
    module: '角色管理',
    description: '修改角色权限配置',
    ipAddress: '192.168.1.101',
    userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
    logLevel: 'warn',
    status: 'failed',
    duration: 500,
    requestMethod: 'PUT',
    requestParams: '{"roleId":2,"permissions":["user:view","user:edit"]}',
    responseResult: '{"code":403,"message":"权限不足"}',
    errorMessage: '用户权限不足，无法修改角色配置'
  },
  {
    id: 4,
    timestamp: new Date('2024-01-15 10:45:00'),
    username: 'admin',
    operationType: 'delete',
    module: '内容管理',
    description: '删除文章：系统使用指南',
    ipAddress: '192.168.1.100',
    userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
    logLevel: 'info',
    status: 'success',
    duration: 180,
    requestMethod: 'DELETE',
    requestParams: '{"articleId":456}',
    responseResult: '{"code":200,"message":"文章删除成功"}',
    errorMessage: null
  },
  {
    id: 5,
    timestamp: new Date('2024-01-15 10:50:00'),
    username: 'user2',
    operationType: 'query',
    module: '日志管理',
    description: '查询系统日志',
    ipAddress: '192.168.1.102',
    userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
    logLevel: 'info',
    status: 'success',
    duration: 250,
    requestMethod: 'GET',
    requestParams: '{"page":1,"size":20,"timeRange":["2024-01-01","2024-01-15"]}',
    responseResult: '{"code":200,"message":"查询成功","data":{"total":15678,"list":[...]}}',
    errorMessage: null
  },
  {
    id: 6,
    timestamp: new Date('2024-01-15 10:55:00'),
    username: 'admin',
    operationType: 'settings',
    module: '系统设置',
    description: '修改系统配置：邮件服务器设置',
    ipAddress: '192.168.1.100',
    userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
    logLevel: 'info',
    status: 'success',
    duration: 420,
    requestMethod: 'PUT',
    requestParams: '{"smtpServer":"smtp.example.com","smtpPort":587}',
    responseResult: '{"code":200,"message":"配置保存成功"}',
    errorMessage: null
  },
  {
    id: 7,
    timestamp: new Date('2024-01-15 11:00:00'),
    username: 'user3',
    operationType: 'export',
    module: '用户管理',
    description: '导出用户列表',
    ipAddress: '192.168.1.103',
    userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
    logLevel: 'info',
    status: 'success',
    duration: 800,
    requestMethod: 'GET',
    requestParams: '{"format":"excel","filters":{"status":"active"}}',
    responseResult: '{"code":200,"message":"导出成功","data":{"fileUrl":"/downloads/users.xlsx"}}',
    errorMessage: null
  },
  {
    id: 8,
    timestamp: new Date('2024-01-15 11:05:00'),
    username: 'admin',
    operationType: 'import',
    module: '内容管理',
    description: '导入文章数据',
    ipAddress: '192.168.1.100',
    userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
    logLevel: 'error',
    status: 'exception',
    duration: 1200,
    requestMethod: 'POST',
    requestParams: '{"file":"articles.xlsx","overwrite":true}',
    responseResult: '{"code":500,"message":"文件格式错误"}',
    errorMessage: '文件格式不支持，请使用正确的Excel格式文件'
  }
]

// 查询日志
const handleQuery = async () => {
  queryLoading.value = true
  try {
    // 模拟查询延迟
    await new Promise(resolve => setTimeout(resolve, 1000))
    
    // 模拟根据查询条件过滤数据
    let filteredData = [...mockLogData]
    
    if (queryForm.username) {
      filteredData = filteredData.filter(log => 
        log.username.toLowerCase().includes(queryForm.username.toLowerCase())
      )
    }
    
    if (queryForm.operationType) {
      filteredData = filteredData.filter(log => 
        log.operationType === queryForm.operationType
      )
    }
    
    if (queryForm.logLevel) {
      filteredData = filteredData.filter(log => 
        log.logLevel === queryForm.logLevel
      )
    }
    
    if (queryForm.ipAddress) {
      filteredData = filteredData.filter(log => 
        log.ipAddress.includes(queryForm.ipAddress)
      )
    }
    
    if (queryForm.module) {
      filteredData = filteredData.filter(log => 
        log.module.includes(queryForm.module)
      )
    }
    
    if (queryForm.status) {
      filteredData = filteredData.filter(log => 
        log.status === queryForm.status
      )
    }
    
    if (queryForm.timeRange && queryForm.timeRange.length === 2) {
      const startTime = new Date(queryForm.timeRange[0])
      const endTime = new Date(queryForm.timeRange[1])
      filteredData = filteredData.filter(log => 
        log.timestamp >= startTime && log.timestamp <= endTime
      )
    }
    
    logList.value = filteredData
    total.value = filteredData.length
    currentPage.value = 1
    
    ElMessage.success(`查询完成，共找到 ${filteredData.length} 条日志`)
  } catch (error) {
    ElMessage.error('查询失败')
  } finally {
    queryLoading.value = false
  }
}

// 重置查询
const resetQuery = () => {
  Object.keys(queryForm).forEach(key => {
    if (Array.isArray(queryForm[key])) {
      queryForm[key] = []
    } else {
      queryForm[key] = ''
    }
  })
  loadLogList()
}

// 刷新日志
const refreshLogs = async () => {
  refreshLoading.value = true
  try {
    await loadLogList()
    ElMessage.success('日志列表已刷新')
  } catch (error) {
    ElMessage.error('刷新失败')
  } finally {
    refreshLoading.value = false
  }
}

// 清空日志
const clearLogs = async () => {
  try {
    await ElMessageBox.confirm(
      '确定要清空所有日志吗？此操作不可恢复！',
      '清空日志确认',
      {
        confirmButtonText: '确定清空',
        cancelButtonText: '取消',
        type: 'warning'
      }
    )
    
    ElMessage.info('正在清空日志...')
    
    // 模拟清空日志
    await new Promise(resolve => setTimeout(resolve, 1500))
    
    logList.value = []
    total.value = 0
    
    ElMessage.success('日志清空成功！')
  } catch (error) {
    if (error !== 'cancel') {
      ElMessage.error('清空日志失败')
    }
  }
}

// 导出日志
const exportLogs = async () => {
  exportLoading.value = true
  try {
    ElMessage.info('正在导出日志...')
    
    // 模拟导出延迟
    await new Promise(resolve => setTimeout(resolve, 2000))
    
    ElMessage.success('日志导出成功！文件已保存到下载目录')
  } catch (error) {
    ElMessage.error('导出失败')
  } finally {
    exportLoading.value = false
  }
}

// 查看日志详情
const viewLogDetail = (log) => {
  selectedLog.value = log
  logDetailVisible.value = true
}

// 选择日志
const handleSelectionChange = (selection) => {
  selectedLogs.value = selection
}

// 分页处理
const handleSizeChange = (val) => {
  pageSize.value = val
  currentPage.value = 1
}

const handleCurrentChange = (val) => {
  currentPage.value = val
}

// 加载日志列表
const loadLogList = async () => {
  tableLoading.value = true
  try {
    // 模拟加载延迟
    await new Promise(resolve => setTimeout(resolve, 500))
    
    logList.value = [...mockLogData]
    total.value = mockLogData.length
  } catch (error) {
    ElMessage.error('加载日志列表失败')
  } finally {
    tableLoading.value = false
  }
}

// 格式化日期时间
const formatDateTime = (date) => {
  return new Date(date).toLocaleString('zh-CN')
}

// 获取操作类型颜色
const getOperationTypeColor = (type) => {
  const colors = {
    login: 'success',
    logout: 'info',
    query: 'primary',
    create: 'success',
    update: 'warning',
    delete: 'danger',
    export: 'primary',
    import: 'warning',
    settings: 'info'
  }
  return colors[type] || 'info'
}

// 获取操作类型文本
const getOperationTypeText = (type) => {
  const texts = {
    login: '登录',
    logout: '登出',
    query: '查询',
    create: '新增',
    update: '修改',
    delete: '删除',
    export: '导出',
    import: '导入',
    settings: '设置'
  }
  return texts[type] || type
}

// 获取日志级别颜色
const getLogLevelColor = (level) => {
  const colors = {
    info: 'primary',
    warn: 'warning',
    error: 'danger',
    debug: 'info'
  }
  return colors[level] || 'info'
}

// 获取状态颜色
const getStatusColor = (status) => {
  const colors = {
    success: 'success',
    failed: 'danger',
    exception: 'warning'
  }
  return colors[status] || 'info'
}

// 获取状态文本
const getStatusText = (status) => {
  const texts = {
    success: '成功',
    failed: '失败',
    exception: '异常'
  }
  return texts[status] || status
}

// 模拟初始数据
onMounted(async () => {
  console.log('LogManagement组件已挂载')
  
  // 加载日志列表
  await loadLogList()
})
</script>

<style scoped>
.log-management-bg {
  width: 100%;
  min-height: calc(100vh - 140px);
  background: #f5f7fa;
  padding: 20px;
  overflow-x: hidden;
}

.log-management-center {
  width: 100%;
  background: transparent;
  border-radius: 0;
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.log-header {
  text-align: center;
  margin-bottom: 30px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.log-avatar {
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 30px;
  font-size: 32px;
  color: white;
  box-shadow: 0 15px 30px rgba(102, 126, 234, 0.3);
}

.log-title {
  font-size: 32px;
  font-weight: 700;
  color: #2c3e50;
  margin-bottom: 8px;
}

.log-subtitle {
  color: #7f8c8d;
  font-size: 16px;
  margin: 0;
}

.log-overview {
  width: 100%;
  margin-bottom: 30px;
  padding: 0 20px;
}

.overview-card {
  background: white;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  gap: 15px;
  transition: all 0.3s ease;
}

.overview-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.card-icon {
  width: 50px;
  height: 50px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: white;
}

.card-content {
  flex: 1;
}

.card-number {
  font-size: 24px;
  font-weight: 700;
  color: #2c3e50;
  margin-bottom: 5px;
}

.card-label {
  color: #7f8c8d;
  font-size: 14px;
}

.log-management {
  width: 100%;
  padding: 0 20px;
}

.query-section {
  margin-bottom: 20px;
}

.query-card {
  border-radius: 16px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-actions {
  display: flex;
  gap: 10px;
}

.query-form {
  padding: 20px 0;
}

.log-list-section {
  margin-bottom: 20px;
}

.log-list-card {
  border-radius: 16px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.pagination-container {
  margin-top: 20px;
  display: flex;
  justify-content: center;
}

.log-detail-dialog {
  border-radius: 16px;
}

.log-detail {
  padding: 20px 0;
}

.detail-section {
  margin: 20px 0;
}

.detail-section h5 {
  margin-bottom: 10px;
  color: #2c3e50;
  font-size: 16px;
}

.detail-section p {
  color: #606266;
  line-height: 1.6;
  margin: 0;
}

.detail-card {
  background: #f8f9fa;
  border: 1px solid #e1e8ed;
  max-height: 200px;
  overflow-y: auto;
}

.detail-card pre {
  margin: 0;
  padding: 10px;
  font-size: 12px;
  color: #606266;
  white-space: pre-wrap;
  word-break: break-all;
}

.error-card {
  background: #fef0f0;
  border-color: #fbc4c4;
}

.error-card pre {
  color: #f56c6c;
}

/* 深度样式修改 */
:deep(.el-input__wrapper) {
  border-radius: 12px;
  border: 2px solid #e1e8ed;
  background: #f8f9fa;
  transition: all 0.3s ease;
  min-height: 48px;
}

:deep(.el-input__wrapper:hover) {
  border-color: #667eea;
  background: white;
}

:deep(.el-input__wrapper.is-focus) {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
  background: white;
}

:deep(.el-select) {
  width: 100%;
}

:deep(.el-form-item__label) {
  font-weight: 600;
  color: #2c3e50;
}

:deep(.el-table) {
  border-radius: 12px;
  overflow: hidden;
}

:deep(.el-table th) {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  font-weight: 600;
}

/* 响应式设计 */
@media (max-width: 1024px) {
  .log-management-center {
    padding: 15px 10px;
  }
  
  .log-title {
    font-size: 28px;
  }
  
  .log-avatar {
    width: 70px;
    height: 70px;
    font-size: 28px;
  }
  
  .overview-card {
    padding: 15px;
  }
  
  .card-icon {
    width: 40px;
    height: 40px;
    font-size: 20px;
  }
  
  .card-number {
    font-size: 20px;
  }
  
  .header-actions {
    flex-direction: column;
    gap: 5px;
  }
}

@media (max-width: 600px) {
  .log-management-center {
    padding: 10px 5px;
  }
  
  .log-title {
    font-size: 24px;
  }
  
  .log-avatar {
    width: 60px;
    height: 60px;
    font-size: 24px;
  }
  
  .card-header {
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
  }
  
  .header-actions {
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .log-management-center {
    padding: 8px 4px;
  }
  
  .log-title {
    font-size: 20px;
  }
  
  .log-avatar {
    width: 50px;
    height: 50px;
    font-size: 20px;
  }
  
  .overview-card {
    padding: 10px;
  }
  
  .card-icon {
    width: 30px;
    height: 30px;
    font-size: 16px;
  }
  
  .card-number {
    font-size: 16px;
  }
  
  .card-label {
    font-size: 12px;
  }
  
  .header-actions {
    gap: 4px;
  }
  
  .header-actions .el-button {
    padding: 6px 10px;
    font-size: 12px;
  }
}

@media (min-width: 1440px) {
  .log-management-center {
    padding: 30px 20px;
  }
  
  .log-title {
    font-size: 36px;
  }
  
  .log-avatar {
    width: 90px;
    height: 90px;
    font-size: 36px;
  }
}

@media (min-width: 1920px) {
  .log-management-center {
    padding: 40px 30px;
  }
  
  .log-title {
    font-size: 40px;
  }
  
  .log-avatar {
    width: 100px;
    height: 100px;
    font-size: 40px;
  }
}
</style>